using System.Windows.Forms;
using CartoGraphic.Model2;
using System.Collections.Generic;

namespace CartoGraphic.MyTool
{
	internal abstract class ToolObj : BaseTool
	{
		private Cursor cursor;

		protected Cursor Cursor
		{
			get { return cursor; }
			set { cursor = value; }
		}

		public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e)
		{
			string al = drawArea.TheLayers.ActiveLayerIndex;
            if (al == null)
                return;
			if (drawArea.TheLayers[al].Graphics.Count > 0)
				drawArea.TheLayers[al].Graphics[0].Normalize();
			drawArea.Capture = false;
			drawArea.Refresh();
		}

		protected void AddNewObject(DrawArea drawArea, BaseDrawingObj o)
		{
			string al = drawArea.TheLayers.ActiveLayerIndex;
            if (al == null)
                return;
			drawArea.TheLayers[al].Graphics.UnselectAll();

			o.Selected = true;
			o.Dirty = true;
			int objectID = 0;
            foreach (KeyValuePair<string, Layer1> pair in drawArea.TheLayers.layerlist)
                objectID += pair.Value.Graphics.Count;
			objectID++;
			o.ID = objectID;
			drawArea.TheLayers[al].Graphics.Add(o);

			drawArea.Capture = true;
			drawArea.Refresh();
		}
	}
}